package Models;

import DB.DBCustomer;
import DB.DBRound;
import DB.RowAbstract;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.9C884431-B57B-3D8F-6088-51A873F93B36]
// </editor-fold> 
public class Location extends RowAbstract
{
	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.A697905D-6AED-FCF1-C9BD-CEB661059483]
	// </editor-fold> 
	private int locationNo;

	private Customer customer;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.B705D9F8-2E2A-47F6-F372-0232CC9D2590]
	// </editor-fold> 
	private String address;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.676ED151-A6E1-6BFD-081E-92FFCFA8AE7A]
	// </editor-fold> 
	private int zipCode;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.8189001D-DA9D-EEB4-8885-921A86B85D4D]
	// </editor-fold> 
	private String city;

	private Checkpoint checkpoint;

	private ArrayList<Round> rounds;

	private int routeNo;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
	// #[regen=yes,id=DCE.5204F16E-020B-CA29-98C4-DA4CCEB4209F]
	// </editor-fold>
	public Location ()
	{}

	public void importData(ResultSet data) throws SQLException
	{
		this.setLocationNo(data.getInt("locationNo"));
		this.setAddress(data.getString("address"));
		this.setZipCode(data.getInt("zipCode"));
		this.setCity(data.getString("city"));
		this.setCheckpoint(new Checkpoint(data.getDouble("longtitude"), data.getDouble("latitude")));
		this.setRouteNo(data.getInt("routeNo"));
		this.fetchDependentData(data.getInt("customerNo"));
	}

	public void fetchDependentData(int customerNo)
	{
		DBCustomer dbc = new DBCustomer();
		this.setCustomer(dbc.fetchRow("customerNo = "+customerNo, null));
		DBRound dbr = new DBRound();
		this.setRounds(dbr.fetchAll("locationNo = "+locationNo, null, 0));
	}

	public static String[] getSearchColumns()
	{
		return new String[] { "locationNo", "address", "zipCode", "city", "longtitude", "latitude", "routeNo" };
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.04B396BE-CA15-52A6-9B57-7F8657D779EA]
	// </editor-fold>
	public String getAddress () {
		return address;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.5FA8A703-D825-ACE4-8CA1-048B70453FB1]
	// </editor-fold> 
	public void setAddress (String val) {
		address = val;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.698B5E22-272A-0BBA-5905-AEAC188A8BE6]
	// </editor-fold> 
	public String getCity () {
		return city;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.26DB12EF-A406-58DE-2AA3-4D5C383AE652]
	// </editor-fold> 
	public void setCity (String val) {
		city = val;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.FCF72CCB-8192-7054-4378-A6CD88CB3599]
	// </editor-fold> 
	public Checkpoint getCheckpoint () {
		return checkpoint;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.96F71A88-91A1-A68D-9823-CA5551BEC66F]
	// </editor-fold> 
	public void setCheckpoint (Checkpoint val) {
		checkpoint = val;
	}

	public Customer getCustomer()
	{
		return customer;
	}

	public void setCustomer(Customer customer)
	{
		this.customer = customer;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
	// #[regen=yes,regenBody=yes,id=DCE.A8B91B36-4938-131A-61BC-DCB053ED4053]
	// </editor-fold>
	public int getLocationNo () {
		return locationNo;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
	// #[regen=yes,regenBody=yes,id=DCE.14F506A4-5DCE-8352-0BEB-9320F1799B68]
	// </editor-fold>
	public void setLocationNo (int val) {
		locationNo = val;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.FE9EBE1F-8B09-C150-22AE-8941730ED295]
	// </editor-fold> 
	public ArrayList<Round> getRounds () {
		return rounds;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.CF5C2CE8-B8B0-FC2A-16DF-B81F9E3D3B3D]
	// </editor-fold> 
	public void setRounds (ArrayList<Round> val) {
		rounds = val;
	}

	public int getRouteNo()
	{
		return routeNo;
	}

	public void setRouteNo(int val)
	{
		this.routeNo = val;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.491C37BE-3AC6-3D4A-6BD3-6580005659E3]
	// </editor-fold> 
	public int getZipCode () {
		return zipCode;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.06E6F5C6-5C23-DC3F-2FF4-66211102008E]
	// </editor-fold> 
	public void setZipCode (int val) {
		zipCode = val;
	}
}